<?php namespace Common\Model;
use Hdphp\Model\Model;
class User extends Model{
	protected $table='user';
	protected $auto=[
		['password','md5','function',3,3]
	];
	//执行自动验证
	protected $validate=[
		['account','required','手机号必填',3,3],
		['username','required','用户名必填',3,3],
		['username','_user','用户名已经被注册',3,3],
		['password','required','密码必填',3,3],
		['password','minlen:6','密码不得少于6位',3,3],
		['conpassword','required','确认密码必填',3,3],
		['conpassword','_pass','两次密码不一致',3,3]

	];
	public function _user(){
		// $username=implode(',', $this->lists('username'));
		$username=Q('post.username');
		$data=$this->where("username=$username")->find();
		if ($data) return false;
		return true;
	}
	public function _pass(){
		$oldPass=Q('post.password');
		$newPass=Q('post.conpassword');
		if($newPass==$oldPass){
			return true;
		}
		return false;
	}
	public function store(){
		if(!$this->create()) return false;
		// p(Q('post.'));
		$this->add();
		return true;
	}
	public function log(){
		if(!$this->create()) return false;
		exit;
		return true;
	}
}
